-- @owner: @zhanghuan96
-- @date: 2024/9/23
-- @testpoint: 对 char_length(str) 函数自定义函数中进行验证
@conn PrimaryDbBmode;
--step1:创建表 expect: 建表成功
drop table if exists t_char_length_0016;
create table t_char_length_0016(column1 int ,column2 float8);

--step2:创建函数向表中插入数据包含log()函数并打印输出 expect: 打印数据成功
drop FUNCTION if exists f_insert_0016;
CREATE OR REPLACE FUNCTION f_insert_0016()
RETURNS void AS
$$
DECLARE
    insert_str TEXT;
BEGIN
    insert_str := 'INSERT INTO t_char_length_0016 (column1, column2) VALUES '
                || '(10, char_length(CAST(2.0000000000001 AS TEXT))),'
                || '(20, char_length(CAST(3 AS TEXT))),'
                || '(30, char_length(CAST(4.599789164 AS TEXT)));';
    EXECUTE insert_str;
END;
$$ LANGUAGE plpgsql;
/
--step3: 调用函数,向表中插入数据 expect: 插入数据成功
call f_insert_0016();

--step4:查看数据 expect:查看数据成功
select * from t_char_length_0016;

--step5:清理环境 expect:成功
drop function if exists f_insert_0016;
drop table if exists t_char_length_0016;
